//: Playground - noun: a place where people can play

import UIKit


// 1. 之前的as使用
let str = "www.baidu.com"
(str as NSString).substring(to: 3)

// 2. as?
let dict : [String : Any] = ["name" : "Alex", "age" : 18]

let tempName = dict["name"]
let name = tempName as? String
if let name = name {
    print(name)
}

// 可以直接这么写
if let name = dict["name"] as? String {
    print(name)
}

// 3. as!
// 通过as!转为具体类型
// 如果转化不成功, 就会直接崩溃
let tempName1 = dict["name"]
let name1 = tempName1 as! String


